const mongoose = require('mongoose');
// 链接数据库
mongoose.connect('mongodb://localhost/studentList');
const schema = new mongoose.Schema({
    name: {
        type: String,
        required: true
    },
    age: {
        type: Number,
        required: true
    },
    sex: {
        type: String,
        required: true,
        default: 0,
        enum: [0, 1]
    },
    address: {
        type: String,
        required: true
    }
});

// 建立模型 直接导出
module.exports = mongoose.model('Student', schema);
